Promise.resolve().then(() => {
  console.log(2)
})

new Promise((resolve) => {
  console.log(3)
  resolve("")
})
.then(() => {
  console.log(4)
}).then(() => {
  console.log(8)
})

process.nextTick(() => {
  console.log(5)
})

setTimeout(() => {
  console.log(6)
}, 0)

setImmediate(() => {
  console.log(7)
})
console.log(1)

// 3 1 2 4 8 5 7 6